fix: add monthly budget support to dashboard#364
Merged
Conversation
The dashboard budget endpoints only handled daily_usd, silently resetting monthly_usd to the $200 default on every update. This meant any custom monthly budget was lost whenever the daily budget was changed. Fix: - api_update_budget: accept optional monthly_usd, preserve current value when not provided - agent edit endpoint: same treatment for the budget field - Dashboard JS: add budget_monthly to edit form, send both values - Dashboard HTML: add monthly budget input field Both endpoints now read the current budget before calling set_budget() so updating one limit doesn't reset the other.
The try/float()/> 0/except pattern was duplicated 4 times across the two budget endpoints. Extracted into a single module-level helper that validates, converts, or falls back to the current value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The dashboard budget endpoints only handled
daily_usd, silently resettingmonthly_usdto the $200 default on every update. This meant any custom monthly budget was lost whenever the daily budget was changed.Root Cause
CostTracker.set_budget()takes bothdaily_usdandmonthly_usdwith defaults, but both dashboard endpoints only passeddaily_usd, somonthly_usdalways reset to200.0.Fix
PUT /api/agents/{id}/budget: Accept optionalmonthly_usd, read current budget before updating so the other limit is preservedPUT /api/agents/{id}(general edit): Same treatment for the budget fieldbudget_monthlyto edit form, send both values to APITesting
set_budget(agent, daily_usd=100)resets monthly to $200